#!/usr/bin/env python
"""
# -*- coding: utf-8 -*-
# @Time    : 2020/9/27 17:25
# @Author  : AshJo
# @Desc    : 服务端
# @Filename: server.py
# @Version : v1.0
"""

import socket

sk = socket.socket()
sk.bind(('127.0.0.1', 9000))
sk.listen()

while True:
    conn, addr = sk.accept()
    while True:
        send_msg = input('>>>').strip()
        conn.send(send_msg.encode('utf-8'))
        if send_msg.upper() == 'Q':
            break
        msg = conn.recv(1024).decode('utf-8')
        if msg.upper() == 'Q':
            break
        print(msg)
    conn.close()

sk.close()
